package demo4;

/**
 * ClassName Computer
 * Description TODO
 * Author Yanyan
 * Date 2025/11/13 13:53
 * Version 1.0
 */
public class Computer {
    public void powerOn() {
        System.out.println("启动电脑！");
    }

    public void powerOff() {
        System.out.println("关闭电脑！");
    }

    public void useDevice(USB usb) {
        usb.openDevice();
        if(usb instanceof Keyboard) {
            Keyboard keyboard = (Keyboard)usb;
            keyboard.input();
        } else if (usb instanceof Mouse) {
            Mouse mouse = (Mouse) usb;
            mouse.click();
        }
        usb.closeDevice();
    }
}
